package com.thoughtworks.Java;

import com.thoughtworks.Java.model.Customer;
import com.thoughtworks.Java.service.CustomerService;
import org.springframework.context.ApplicationContext;
import org.springframework.context.annotation.AnnotationConfigApplicationContext;

import java.util.List;

/**
 * Created by yrzhang on 10/9/16.
 */
public class Application {

    public List<Customer> showCustomers() {
        ApplicationContext appContext = new AnnotationConfigApplicationContext(AppConfig.class);

        CustomerService service = appContext.getBean("customerService", CustomerService.class);

        return service.findAll();
    }

    public String getName() {

        ApplicationContext appContext = new AnnotationConfigApplicationContext(AppConfig.class);

        CustomerService service = appContext.getBean("customerService", CustomerService.class);
        return service.getName();
    }
}
